package com.gjq.jdbcapi.controller;

import com.gjq.jdbcapi.common.Result;
import com.gjq.jdbcapi.dao.sjrzDao;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@RestController
@RequestMapping("/sjrz_heat")
public class sjrzController {

    @Resource
    private sjrzDao sjrz;

    @GetMapping("/simFind")
    public Result simFind(int hour){

        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();

        // 设置小时
        LocalDateTime customTime = now.withHour(hour).withMinute(0).withSecond(0);
        LocalDateTime customTime2 = now.withHour(hour+1).withMinute(0).withSecond(0);

        // 格式化时间
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String Time = customTime.format(formatter);
        String Time2 = customTime2.format(formatter);
        return Result.success(sjrz.simpleFind(Time,Time2));
    }

}
